<?php


namespace app\common\model\mysql;


use think\Exception;
use think\Model;

class GoodsSku extends Model
{
    public function goods()
    {
        return $this->hasOne(Goods::class, 'id', 'goods_id');
    }

    public function getNormalIndIds($sku_ids)
    {
        try {
            $res = $this->whereIn('id', $sku_ids)->select()->toArray();
        } catch (Exception $e) {
            throw  new \Exception($e->getMessage());
        }

        return $res;
    }

    public function DecStock($id, $num)
    {
        return $this->where(['id' => $id])->dec('stock',$num)->update();
    }
}